﻿using System;
namespace Producers.Kis.Xtee.Riik.Ee.Producer.Kis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="MKMNotification", Namespace="http://producers.kis.xtee.riik.ee/producer/kis", Target=typeof(MKMNotification))]
    public class MKMNotificationSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMKMNotification clazz;
        
        public MKMNotificationSerializer(IMKMNotification clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("SpecifiedName");
            if (clazz.SpecifiedName!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SpecifiedName))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SpecifiedName");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Identificator");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Identificator))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="SpecifiedName") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>MKMNotification>SpecifiedName");
                }
                clazz.SpecifiedName = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("SpecifiedName")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>MKMNotification>SpecifiedName", Reader.LocalName);
            }
            if (Reader.LocalName=="Identificator") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>MKMNotification>Identificator");
                }
                clazz.Identificator = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("Identificator")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>MKMNotification>Identificator", Reader.LocalName);
            }
        }
    }
}
